Skip to content

fix: #457 Parameters from PathItem can now be overriden in Operation #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 60 commits into from
Aug 15, 2021

Conversation

mtovts
Copy link
Contributor

@mtovts mtovts commented Jul 27, 2021

This PR aims to fix the code generation with PathItems parameters overriding
in Operation. Please, read more in #457 .

Seems like overriding is job for set and __hash__ overriding. But Property class is
defined with @attr.s(auto_attribs=True, frozen=True). And how to achieve __hash__
overriding with + frozen=True is not obvious. It is the reason for using dict.

  • Parameter location list-s replaced with dict-s because it allows to
    build Endpoint.from_data() with Operation parameters then add PathItem
    parameters in EndpointCollection.from_data() by dict.setdefault() to avoid Operation
    parameters overriding with PathItem parameters.

  • Removes from Endpoint._add_parameters

    return ParseError(data=param, detail="Parameter must be declared in path or query"), schemas

    Because parameter with location other than listed in ParameterLocation(str, Enum) will
    not be validated by pydantic. So why do we need to check that case here twice?

  • Add more obvious warning in duplicated parameters case.

  • Always use {param.name}_{param.param_in} python identifier for parameters because it leads
    to more obvious usage and simplifies the code.

    Please, pay attention to test__add_parameters_happy
    in tests\test_parser\test_openapi.py. I'm not sure if I have done it best way there.

Custom templates in end-to-end tests did not pass. I believe I haven't touched them, but it
fails. I made it passing by making imports relative. I ran it on Windows, so maybe it fixes #447 ?

mtovts added 27 commits July 22, 2021 11:36
…ly if got the parameters with the same name
@mtovts
Copy link
Contributor Author

mtovts commented Jul 31, 2021

Always use {param.name}_{param.param_in} python identifier for parameters because it leads
to more obvious usage and simplifies the code.

I shouldn’t have changed that behavior. I brought it back and fixed it for this PR.

@mtovts
Copy link
Contributor Author

mtovts commented Aug 9, 2021

@dbanty Thank you for the review! Added your suggestions and a test for the case you described. Also added forgotten used_python_identifiers usage. It is ready now. Should we create a new issue for the behavior I've suggested to resolve identifiers conflict?

@mtovts mtovts requested a review from dbanty August 9, 2021 09:42
Copy link
Collaborator

@dbanty dbanty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping up with this! I have one fix to an error message and a couple suggested refactors for easier readability (subjectively).

@mtovts
Copy link
Contributor Author

mtovts commented Aug 15, 2021

@dbanty Dylan, thanks for these improvements! I agree, and also added the missing test 👀

@mtovts mtovts requested a review from dbanty August 15, 2021 10:44
@codecov
Copy link

codecov bot commented Aug 15, 2021

Codecov Report

Merging #458 (ca7c30f) into main (52eb8d0) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #458   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           47        47           
  Lines         1589      1592    +3     
=========================================
+ Hits          1589      1592    +3     
Impacted Files Coverage Δ
openapi_python_client/parser/openapi.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 52eb8d0...ca7c30f. Read the comment docs.

Copy link
Collaborator

@dbanty dbanty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more tweak, sorry I didn't clarify in the last round.

@dbanty
Copy link
Collaborator

dbanty commented Aug 15, 2021

Everything else looks good so I'm gonna try and tweak this myself real quick so you don't have to jump in here again.

Copy link
Collaborator

@dbanty dbanty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for all your work on this!

@dbanty dbanty enabled auto-merge (squash) August 15, 2021 16:27
@dbanty dbanty disabled auto-merge August 15, 2021 16:31
@dbanty dbanty merged commit 53cdd94 into openapi-generators:main Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get tests passing on Windows
2 participants